using System;
using System.Collections.Generic;
using System.Text;
using ClimbTracker.BusinessLogic.Dao;

namespace ClimbTracker.BusinessLogic.Entities
{
    public sealed class DBManager
    {
        #region Members

        private CompetitorDao _competitorDao;
        private CompetitionDao _competitionDao;
        private RouteDao _routeDao;
        private ClimbAttemptDao _climbAttemptDao;
        private WallInstallationDao _wallInstallationDao;

        private static DBManager instance = null;
        private static readonly object padlock = new object();

        #endregion





        public static DBManager Instance
        {
            get
            {
                lock (padlock)
                {
                    if (instance == null)
                    {
                        instance = new DBManager();
                    }
                    return instance;
                }
            }
        }



        /// <summary>
        /// Constructor: initializes all DAOs (data access objects).
        /// The DBManager holds these DAOs as the main access point to the database.
        /// </summary>
        private DBManager()
        {
            this.ClimbAttemptDao = new ClimbAttemptDao();
            this.CompetitionDao = new CompetitionDao();
            this.CompetitorDao = new CompetitorDao();
            this.RouteDao = new RouteDao();
        }








        public CompetitorDao CompetitorDao
        {
            get { return _competitorDao; }
            set { _competitorDao = value; }
        }

        public CompetitionDao CompetitionDao
        {
            get { return _competitionDao; }
            set { _competitionDao = value; }
        }

        public RouteDao RouteDao
        {
            get { return _routeDao; }
            set { _routeDao = value; }
        }

        public ClimbAttemptDao ClimbAttemptDao
        {
            get { return _climbAttemptDao; }
            set { _climbAttemptDao = value; }
        }

        public WallInstallationDao WallInstallationDao
        {
            get { return _wallInstallationDao; }
            set { _wallInstallationDao = value; }
        }


    }
}
